package cn.itcast.order.service;

import cn.itcast.order.mapper.OrderMapper;
import cn.itcast.order.pojo.Order;
import com.yipingtai.api.UserClient;
import com.yipingtai.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private UserClient userClient;

    public Order queryOrderById(Long orderId) {
        // 1.查询订单
        Order order = orderMapper.findById(orderId);

        User byId = userClient.findById(order.getUserId());

        User user = userClient.getUser("小白", "地球");
        System.out.println("获取到的用户信息:"+user);
        //设置用户的数据
        order.setUser(byId);
        // 4.返回
        return order;
    }
}
